<template>
  <div>
    <el-container>
      <!-- 侧边栏 el-aside一般是要设置高度的 vh就是把浏览器分为100等份，值为多少就是多少份-->
      <!-- 侧边栏要配置menu收缩的话，width就不能写死 -->
      <el-aside :width="asideWidth" style="min-height: 100vh; background-color: #001529;">
        <!-- logo -->
        <div class="logo">
          <img src="@/assets/logo1.png" alt="" style="width: 40px;height: 40px;">
          <span class="logo-title" style="" v-show="!collapse">Shit2024</span>
        </div>

        <!-- menu区 一般是会把边框设置掉 -->
        <!-- default-active是默认高亮，值是高亮menu对应的index属性，如下路由为/的菜单会高亮 -->
        <!-- $route.path是当前的路由，这里这样设置就可以动态高亮了 -->
        <!-- 加上router属性，菜单就可以点击跳转路由了 具体跳转就是index里面的值 -->
        <el-menu :collapse="isCollapse" :collapse-transition="false" background-color="#001529" text-color="rgba(255,255,255,0.65)" active-text-color="#fff" router style="border: none;" :default-active="$route.path">
          <!-- 一级菜单 -->
          <!-- index的值和路由中的path是对应的 这个值只有el-menu-item才生效 -->
          <el-menu-item index="/">
            <i class="el-icon-house"></i>
            <span slot="title" v-if="!collapse">系统首页</span>
          </el-menu-item>

          <el-menu-item index="/element">
            <i class="el-icon-eleme" ></i>
            <span slot="title" v-if="!collapse">ElementUi实验</span>
          </el-menu-item>

          <el-menu-item index="/matLabel">
            <i class="el-icon-box" ></i>
            <span slot="title" v-if="!collapse">物料标签管理</span>
          </el-menu-item>

          <!-- 二级菜单 -->
          <el-submenu>
            <!-- #title等同于v-slot -->
            <template #title>
              <!-- 小图标 -->
              <i class="el-icon-menu" ></i>
              <span v-if="!collapse">信息管理</span>
            </template>
            <el-menu-item >用户信息</el-menu-item>
          </el-submenu>
        </el-menu>

      </el-aside>

      <el-container>

        <!-- 头部 -->
        <el-header>
          <!-- 收缩侧边栏和菜单按钮 -->
          <i :class="collapseIcon" class="el-icon-menu" style="font-size: 26px; " @click="handleCollapse"></i>
          <el-breadcrumb separator-class="el-icon-arrow-right" style="margin-left: 20px">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item :to="{ path: '/user' }">用户管理</el-breadcrumb-item>
          </el-breadcrumb>

          <div style="flex: 1; display: flex; justify-content: flex-end; align-items: center">
            <i class="el-icon-quanping" style="font-size: 25px"></i>
            <el-dropdown placement="bottom">
              <div style="display: flex; align-items: center; cursor: pointer">
                <img src="@/assets/logo1.png" alt="" style="width: 40px; height: 40px; margin: 0 5px">
                <span>管理员</span>
              </div>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item>个人信息</el-dropdown-item>
                <el-dropdown-item>修改密码</el-dropdown-item>
                <el-dropdown-item>退出登录</el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </div>
        </el-header>

        <!-- 主体 -->
        <el-main>
          <router-view></router-view>
        </el-main>

      </el-container>

    </el-container>
  </div>
</template>

<script>

export default {
  name: 'HomeView',
  components: {

  },
  data(){
    return{
      isCollapse:false, // 默认不收缩菜单
      asideWidth:'200px',
      collapseIcon:'el-icon-s-fold'
    }
  },
  methods:{
    handleCollapse(){
      this.collapse = !this.collapse
      this.asideWidth = this.collapse ? '64px':'200px';
      this.collapseIcon = this.isCollapse ? 'el-icon-s-unfold':'el-icon-s-fold';
    }
  }
}
</script>
<style scoped>
.logo{
  height: 60px;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
}
.logo-title{
  margin-left: 5px; 
  font-size: 20px;
  transition: all .3s;
}
/* 子菜单背景色稍微深一点 同时往右移动一点 */
.el-menu--inline .el-menu-item{
  background-color: #000c17 !important;
  padding-left: 49px !important;
}
/* 设置菜单鼠标放上去的时候字体颜色变白 */
.el-menu-item:hover, .el-submenu__title:hover{
  color: #fff !important;
}
/* 给小图标触摸上色 */
.el-submenu__title:hover i{
  color: #fff !important;
}
/* 给当前默认高亮菜单上色 */
.el-menu-item.is-active{
  background-color: #1890ff !important; 
  border-radius: 5px !important;
  margin: 4px !important;
  margin-left: 0px !important
  ;
}
/* 调小菜单的高度 */
.el-menu-item{
  height: 40px !important;
  line-height: 40px !important;
}
.el-submenu__title{
  height: 40px !important;
  line-height: 40px !important;
}
/* 不加deep不会生效，调整小箭头的位置 */
/deep/.el-submenu__icon-arrow {
  margin-top: -3px !important;
}

/* 给侧边栏加上阴影和动画 */
.el-aside {
  transition: width .3s;
  box-shadow: 2px 0 6px rgba(0,21,41,.35);
}
.el-header{
  box-shadow: 2px 0 6px rgba(0,21,41,.35);
  display: flex;
  /* line-height: 60px; */
  align-items: center;
}
</style>